﻿<%-- The following 4 lines are ASP.NET directives needed when using SharePoint components --%>

<%@ Page Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" MasterPageFile="~site/_catalogs/masterpage/PermissionExplorer.master" Language="C#" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%-- The markup and script in the following Content element will be placed in the <head> of the page --%>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <script type="text/javascript" src="../Scripts/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.runtime.debug.js"></script>
        <script type="text/javascript" src="/_layouts/15/SP.js"></script>

    <script type="text/javascript" src="/_layouts/15/SP.UI.Dialog.js"></script>
    <script type="text/javascript" src="/_layouts/15/sp.debug.js"></script>
    <script type="text/javascript" src="/_layouts/15/SP.RequestExecutor.js"></script>

    <!-- Add your CSS styles to the following file -->
    <link rel="Stylesheet" type="text/css" href="../Content/App.css" />

    <!-- Add your JavaScript to the following file -->
    <script type="text/javascript" src="../Scripts/KeyVerification.js"></script>
    <script type="text/javascript" src="../Scripts/checkAppVersion.js"></script>
    <script type="text/javascript" src="../Scripts/AdRotator-1.9.js"></script>
    <script type="text/javascript" src="../Scripts/Analytics-1.2.js"></script>
    <script type="text/javascript" src="../Scripts/MainApp.js?v=1"></script>
    <script type="text/javascript" src="../Scripts/knockout-3.1.0.js"></script>
</asp:Content>

<%-- The markup and script in the following Content element will be placed in the <body> of the page --%>
<asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <div id="divActivate"  style="display: none;">
        <p>This is Free Version, you can upgrade it to the paid version which includes changing permission.</p>
        <div style="margin-left:80px;">
        <button type="button" data-bind="click: $root.onActivate">Activate</button>
        <button type="button" >Buy now</button>
        </div>
    </div>
    <div id="adRotator"></div>
<div id="divMain">
    <div id="divEmpty"> 
        <ul>
            <li><input type="checkbox" data-bind="checked: $root.showLibrary, click: $root.checkGroupandUserEnable"/>    Show Library Role Assignments</li>
            <li><input type="checkbox" data-bind="checked: $root.showList, click: $root.checkGroupandUserEnable"/>   Show List Role Assignments</li>
            <li><input type="checkbox" data-bind="checked: $root.showGroups, click: $root.checkGroupandUserEnable"/>   Show Group Role Assignments</li>
            <li><input type="checkbox" data-bind="checked: $root.showUsers, click: $root.checkGroupandUserEnable"/>  Show User Role Assignments</li>
            <li><input type="checkbox" data-bind="checked: $root.showUniqueAssignments, click: $root.checkUniqueAssignments"/> Only show lists and libraries with unique role assignments</li>

        </ul>
                    <div class="soe-main-list-image-line-1"><img  src="../Images/blueline.png" /></div><p class="title1">Inherits permissions from it's parent.</p>
            <div class="soe-main-list-image-line-2"><img  src="../Images/blackline.png" /></div><p class="title2">Has unique permissions.</p>  
    </div>
       <div  id="divPemission">
       <ul id="listPemission" data-bind="foreach: principleCollection">
           <li data-bind=" attr: { id: String(id), title: title}">
               <div class="rot-neg-90" data-bind="text: title"></div>
           </li>
       </ul>
   </div>
<div id="divData">
       
       <ul id="listData" data-bind="template: { name: 'itemTmpl', foreach: siteCollection }">
       </ul>
</div>

<div id="divChangePermission" style="display: none;"> 
    <!-- ko ifnot: $root.Inheritance --><h1 class="TitlePemission">Change Role Assignments</h1><!-- /ko --><!-- ko if: $root.Inheritance --><h2 class="TitlePemission">View Role Assignments</h2><!-- /ko -->
    <!-- ko if: $root.Inheritance --><p class="PemissionKind">Inherits permissions from its parent. To change it you must break the inheritance.</p><!-- /ko --><!-- ko ifnot: $root.Inheritance --><p class="PemissionKind">Has Unique Role Assignments</p><!-- /ko -->
    <ul data-bind="template: { name: 'ChangePermission', foreach: $root.roleCollection }"></ul>
    <!-- ko ifnot: $root.Inheritance -->
    <button class="buttontype" type="button" data-bind="click: $root.onApplyChangePermission">Apply</button>
    <button class="buttontype" type="button" data-bind="click: $root.onCancelChangePermission">Cancel</button>
    <!-- /ko -->
    <!-- ko if: $root.Inheritance -->
    <button class="buttontype" type="button" data-bind="click: $root.onCancelChangePermission">Close</button>
    <!-- /ko -->

</div>

<script id="ChangePermission" type="text/html">
    <!-- ko if: NotLimittedAcess -->
    <li><div class ="CheckboxPermission"><input class="checkb" type="checkbox" data-bind="checked: roleEnable, disable: $root.Inheritance" /><div class="description" data-bind="text: getDescription"></div></div></li>
    <!-- /ko -->
    <!-- ko ifnot: NotLimittedAcess -->
    <li><div class ="CheckboxPermission"><input class="checkb" type="checkbox" data-bind="checked: roleEnable" disabled="disabled" /><div class="description" data-bind="text: getDescription"></div></div></li>
    <!-- /ko -->
</script>

<script id="itemTmpl" type="text/html">
    
       <div  class="soe-main-list">
       <div class="soe-main-list-image"><img data-bind="click: $root.Navigator, attr: {src: imgSource }" /></div>
       <div class="soe-main-list-title-unique" ><p data-bind="text: formattedName"></p></div>
       <div class="soe-fixed-position" data-bind=" template: { name: 'matrix', foreach: $root.principleCollection }" ></div>
       </div>
       <ul data-bind=" attr: { id: String(id) }" style="display: none;">
           <li data-bind="visible: $root.showLibrary">
               <div  class="soe-main-list">
               <div class="soe-main-list-image"><img data-bind="click: $root.libraryNavigator, attr: {src: imgSourcelibrary }" /></div>
               <div class="soe-main-list-title-unique"><p>Libraries</p></div>
               
               <div class="soe-fixed-position" data-bind=" template: { name: 'emptymatrix', foreach: $root.principleCollection }" ></div>
               </div>
               <ul data-bind=" attr: { id: librarylvl2 }, template: { name: 'libraryTmpl', foreach: libraries }" style="display: none;"></ul>
           </li>
           <li data-bind="visible: $root.showList">
               <div  class="soe-main-list">
               <div class="soe-main-list-image"><img data-bind="click: $root.listNavigator, attr: { src: imgSourcelist }" /></div>
               <div class="soe-main-list-title-unique"><p>Lists</p></div>
               <div class="soe-fixed-position" data-bind=" template: { name: 'emptymatrix', foreach: $root.principleCollection }" ></div>
               </div>
               <ul data-bind=" attr: { id: listlvl2 }, template: { name: 'listTmpl', foreach: lists }" style="display: none;"></ul>
           </li>
           <li>
               <div  class="soe-main-list">
               <div class="soe-main-list-image"><img data-bind="click: $root.subSiteNavigator, attr: { src: imgSourcesubSite }" /></div>
               <div class="soe-main-list-title-unique"><p>Sub Sites</p></div>
               <div class="soe-fixed-position" data-bind=" template: { name: 'emptymatrix', foreach: $root.principleCollection }" ></div>
               </div>
               <ul data-bind=" attr: { id: subSitelvl2 }, template: { name: 'itemTmplLoop', foreach: subSites }" style="display: none;"></ul>
           </li>
    </ul>
    
</script>

<script id="itemTmplLoop" type="text/html">

    <li data-bind=" attr: { class: String(id) }">
       <div  class="soe-main-list">
       <div class="soe-main-list-image"><img data-bind="click: $root.Navigator, attr: { src: imgSource }" /></div>
       <div class="soe-main-list-title" data-bind="visible: !$root.hasUniqueRoleAssignment"><p data-bind="    text: formattedName"></p></div>
       <div class="soe-main-list-title-unique" data-bind="visible: $root.hasUniqueRoleAssignment"><p data-bind="    text: formattedName"></p></div>

       <div class="soe-fixed-position"><div data-bind=" template: { name: 'matrixcell', foreach: $root.principleCollection }" ></div>
        <div class="soe-main-list-image" ><img data-bind="click: $root.changeInheritance, attr: { src: InheriteImgSources, title: InheriteImgTip }" /></div> 
           </div>
       </div>
       <ul data-bind=" attr: { id: String(id) }" style="display: none;">
           <li data-bind="visible: $root.showLibrary">
               <div  class="soe-main-list">
               <div class="soe-main-list-image"><img data-bind="click: $root.libraryNavigator, attr: { src: imgSourcelibrary }" /></div>
               <div class="soe-main-list-title-unique"><p>Libraries</p></div>
               
               <div class="soe-fixed-position" data-bind=" template: { name: 'emptymatrix', foreach: $root.principleCollection }" ></div>
               </div>
               <ul data-bind=" attr: { id: librarylvl2 }, template: { name: 'libraryTmpl', foreach: libraries }" style="display: none;"></ul>
           </li>
           <li data-bind="visible: $root.showList">
               <div  class="soe-main-list">
               <div class="soe-main-list-image"><img data-bind="click: $root.listNavigator, attr: { src: imgSourcelist }" /></div>
               <div class="soe-main-list-title-unique"><p>Lists</p></div>
               <div class="soe-fixed-position" data-bind=" template: { name: 'emptymatrix', foreach: $root.principleCollection }" ></div>
               </div>
               <ul data-bind=" attr: { id: listlvl2 }, template: { name: 'listTmpl', foreach: lists }" style="display: none;"></ul>
           </li>
           <li data-bind="visible: subSites().length > 0">
               <div  class="soe-main-list">
               <div class="soe-main-list-image"><img data-bind="click: $root.subSiteNavigator, attr: { src: imgSourcesubSite }" /></div>
               <div class="soe-main-list-title-unique"><p>Sub Sites</p></div>
               <div class="soe-fixed-position" data-bind=" template: { name: 'emptymatrix', foreach: $root.principleCollection }" ></div>
               </div>
               <ul data-bind=" attr: { id: subSitelvl2 }, template: { name: 'itemTmplLoop', foreach: subSites }" style="display: none;"></ul>
           </li>
    </ul>
    </li>

</script>


<script id="libraryTmpl" type="text/html">

    <li data-bind=" attr: { class: String(id) }">
       <div  class="soe-main-list">
       <div class="soe-main-list-image"><img data-bind="attr: { id: String(id)}"  src="../Images/LibraryI.png" /></div>
       <!-- ko ifnot: hasUniqueRoleAssignment -->
       <div class="soe-main-list-title" ><p data-bind="text: formattedName"></p></div>
            <!-- /ko -->
            <!-- ko if: hasUniqueRoleAssignment -->
       <div class="soe-main-list-title-unique" ><p data-bind="text: formattedName"></p></div>
            <!-- /ko -->
       <div class="soe-fixed-position"><div data-bind=" template: { name: 'matrixcell', foreach: $root.principleCollection }" ></div>
        <div class="soe-main-list-image" ><img data-bind="click: $root.changeInheritance, attr: { src: InheriteImgSources, title: InheriteImgTip }" /></div> 
           </div>
       </div>
    </li>

</script>
<script id="listTmpl" type="text/html">
    
    <li data-bind=" attr: { class: String(id) }">
        <div  class="soe-main-list">
       <div class="soe-main-list-image"><img data-bind="attr: { id: String(id) }"  src="../Images/ListI.png"  /></div>
            <!-- ko ifnot: hasUniqueRoleAssignment -->
       <div class="soe-main-list-title" ><p data-bind="text: formattedName"></p></div>
            <!-- /ko -->
            <!-- ko if: hasUniqueRoleAssignment -->
       <div class="soe-main-list-title-unique" ><p data-bind="text: formattedName"></p></div>
            <!-- /ko -->
        <div class="soe-fixed-position"><div data-bind="  template: { name: 'matrixcell', foreach: $root.principleCollection }" ></div>
        <div class="soe-main-list-image"><img data-bind="click: $root.changeInheritance, attr: { src: InheriteImgSources, title: InheriteImgTip }" /></div> 
        </div>         
        </div>
    </li>

</script>

<script id="matrixcell" type="text/html">
       <div data-bind=" attr: { class: String(id) }">
           <!-- ko ifnot: $root.sysLoading -->
               <!-- ko ifnot: $parent.hasUniqueRoleAssignment --><div  class="soe-main-matrix-image"   >
               <div class="soe-main-matrix-text" data-bind="    text: $root.getPrincipalRole(principal, $parent), attr: { title: $root.getTip(principal, $parent) }, click: $root.onChangePermission.bind(principal, $parent)"></div></div><!-- /ko -->
               <!-- ko if: $parent.hasUniqueRoleAssignment --><div  class="soe-main-matrix-image-unique"   >
               <div class="soe-main-matrix-text" data-bind="    text: $root.getPrincipalRole(principal, $parent), attr: { title: $root.getTip(principal, $parent) }, click: $root.onChangePermission.bind(principal, $parent)"></div></div><!-- /ko -->
           <!-- /ko -->
           <!-- ko if: $root.sysLoading -->
               <div  class="soe-main-matrix-image"   >
               </div>   
           <!-- /ko -->

       </div>
</script>



<script id="matrix" type="text/html">
       <div data-bind=" attr: { class: String(id) }"><div  class="soe-main-matrix-image-unique"   ><div class="soe-main-matrix-text" data-bind="    text: $root.getPrincipalRole(principal, $parent), attr: { title: $root.getTip(principal, $parent) }, click: $root.onChangePermission.bind(principal, $parent)"></div></div></div>
</script>

<script id="emptymatrix" type="text/html">
       <div data-bind=" attr: { class: String(id) }"><div  class="soe-main-matrix-image"  ></div></div>
</script>





</div>
</asp:Content>
